<?php 
$cs=Yii::app()->clientScript;
$cs->registerCssFile(Yii::app()->baseUrl.'/css/common.css');
$cs->registerScript('driver_accident_dialog',<<<END
$(".recommend").click(function(){
p=window.prompt('请输入推荐值(1-100)','1');
if(!p) return false;
if($.trim(p)==''||isNaN(p)||p<0||p>100) {alert('请输入整数(1-100)!');return false;};
$(this).attr('href',$(this).attr('href')+'&recommend='+p);
});
$("#sel_all").toggle(
function(){
	$(this).val('全否');
	$("input[type=checkbox]").attr("checked",true);
},
function(){
	$(this).val('全选');
	$("input[type=checkbox]").attr("checked",false);
}
);
$("form:eq(1)").submit(
function(){
	if($("input[type=checkbox]:checked").length==0){alert("请选择要删除的信息!");return false;}
	return confirm('确定要删除已选中信息吗？');
});
END
);
?>
<h2>厂家管理</h2>
<?php echo CHtml::beginForm(array('business_admin'),'post');?>
审核/未审核：<?php echo CHtml::dropDownList('keys[business.state]', isset($_GET['keys']['business.state'])?$_GET['keys']['business.state']:'', array(''=>'全部','0'=>'审核','2'=>'未审核'));?>
文字推荐：<?php echo CHtml::dropDownList('keys[recommend1]', isset($_GET['keys']['recommend1'])?$_GET['keys']['recommend1']:'', array(''=>'全部','1'=>'是','0'=>'否'));?>
全部推荐：<?php echo CHtml::dropDownList('keys[recommend2]', isset($_GET['keys']['recommend2'])?$_GET['keys']['recommend2']:'', array(''=>'全部','1'=>'是','0'=>'否'));?>
分类推荐：<?php echo CHtml::dropDownList('keys[recommend3]', isset($_GET['keys']['recommend3'])?$_GET['keys']['recommend3']:'', array(''=>'全部','1'=>'是','0'=>'否'));?>
分类：<?php echo CHtml::dropDownList('keys[product_sort]', isset($_GET['keys']['product_sort'])?$_GET['keys']['product_sort']:'',$product_sorts);?>
厂家名称：<input type="text" name="keys[business.name]" size="7" value="<?php echo isset($_GET['keys']['business.name'])?$_GET['keys']['business.name']:'';?>"/>
模糊查询：<?php echo CHtml::radioButtonList('keys[blur]',isset($_GET['keys']['blur'])?$_GET['keys']['blur']:'1', array('1'=>'是','0'=>'否'),array('separator'=>''));?>
<input type="submit" value="搜索"/>
<?php echo CHtml::endForm();?>
<?php echo CHtml::beginForm(array('set_business_state')+$_GET,'post');?>
<input id="sel_all" type="button" value="全选"/><input type="submit" value="删除选中"/>
<table class="dataGrid" width="1070">
  <thead>
  <tr>
  	<th width="30">选择</th>
    <th width="150"><?php echo $sort->link('name'); ?></th>
    <th width="60"><?php echo $sort->link('brand'); ?></th>
    <th width="80"><?php echo $sort->link('username'); ?></th>
    <th width="80"><?php echo $sort->link('password'); ?></th>
    <th width="40"><?php echo $sort->link('product_sum'); ?></th>
    <th width="70"><?php echo $sort->link('province_name'); ?></th>
    <th width="50"><?php echo $sort->link('state'); ?></th>
    <th width="100"><?php echo $sort->link('update_time'); ?></th>
    <th width="30"><?php echo $sort->link('recommend1'); ?></th>
    <th width="30"><?php echo $sort->link('recommend2'); ?></th>
    <th width="30"><?php echo $sort->link('recommend3'); ?></th>
    <th width="200">推荐操作</th>
	<th width="120">操作</th>
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
  	<td><input type="checkbox" name="ids[]" value="<?php echo $model->id;?>"/></td>
  	<?php $url=array('business/get_business','id'=>$model->id)+$_GET;?>
  	<td><?php echo CHtml::link($model->name,$url,array('target'=>'_blank')); ?></td>
  	<td><?php echo CHtml::encode($model->brand); ?></td>
    <td><?php echo CHtml::encode($model->username); ?></td>
    <td><?php echo CHtml::encode($model->password); ?></td>
    <td><?php echo CHtml::encode($model->product_sum); ?></td>
    <td><?php echo CHtml::encode($model->province_name); ?></td>
    <td><?php echo CHtml::encode($model->state==0?'审核':'未审核'); ?></td>
    <td><?php echo CHtml::encode($model->update_time); ?></td>
    <td><?php echo CHtml::encode($model->recommend1);?></td>
    <td><?php echo CHtml::encode($model->recommend2);?></td>
    <td><?php echo CHtml::encode($model->recommend3);?></td>
    <td>
     <?php 
     if($model->recommend1==0)
     	echo CHtml::link('文字',array('set_business_recommend','id'=>$model->id,'n'=>1)+$_GET,array('class'=>'recommend'));
     else
     	echo CHtml::link('取消文字',array('set_business_recommend','id'=>$model->id,'n'=>1,'recommend'=>0)+$_GET);	
      ?>&nbsp;&nbsp;
      <?php 
     if($model->recommend2==0)
     	echo CHtml::link('全部',array('set_business_recommend','id'=>$model->id,'n'=>2)+$_GET,array('class'=>'recommend'));
     else
     	echo CHtml::link('取消全部',array('set_business_recommend','id'=>$model->id,'n'=>2,'recommend'=>0)+$_GET);
     ?>&nbsp;&nbsp;
     <?php		
     if($model->recommend3==0)
     	echo CHtml::link('分类',array('set_business_recommend','id'=>$model->id,'n'=>3)+$_GET,array('class'=>'recommend'));
     else
     	echo CHtml::link('取消分类',array('set_business_recommend','id'=>$model->id,'n'=>3,'recommend'=>0)+$_GET);	
      ?>
    </td>
    <td>
     <?php echo CHtml::link('审核',array('set_business_state','id'=>$model->id,'state'=>0)+$_GET); ?>
      <?php echo CHtml::link('未审核',array('set_business_state','id'=>$model->id,'state'=>2)+$_GET); ?>
     <?php echo CHtml::link('删除',array('set_business_state','id'=>$model->id,'state'=>1)+$_GET,array('confirm'=>"确定要删除 {$model->name} 的厂家信息吗？")); ?>
    </td>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
</form>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'htmlOptions'=>array('style'=>'width:900px;'))); ?>